home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_se / run_feature_6.e < prev    next >
Text File  |  2000-03-25  |  6KB  |  225 lines

  1. --          This file is part of SmallEiffel The GNU Eiffel Compiler.
  2. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  3. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr
  4. --                       http://SmallEiffel.loria.fr
  5. -- SmallEiffel is  free  software;  you can  redistribute it and/or modify it
  6. -- under the terms of the GNU General Public License as published by the Free
  7. -- Software  Foundation;  either  version  2, or (at your option)  any  later
  8. -- version. SmallEiffel is distributed in the hope that it will be useful,but
  9. -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. -- or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU General Public License
  11. -- for  more  details.  You  should  have  received a copy of the GNU General
  12. -- Public  License  along  with  SmallEiffel;  see the file COPYING.  If not,
  13. -- write to the  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  14. -- Boston, MA 02111-1307, USA.
  15. --
  16. class RUN_FEATURE_6
  17.  
  18. inherit RUN_FEATURE;
  19.  
  20. creation make
  21.  
  22. feature
  23.  
  24.    base_feature: ONCE_FUNCTION;
  25.  
  26.    arguments: FORMAL_ARG_LIST;
  27.  
  28.    result_type: TYPE;
  29.  
  30.    require_assertion: RUN_REQUIRE;
  31.  
  32.    local_vars: LOCAL_VAR_LIST;
  33.  
  34.    routine_body: COMPOUND;
  35.  
  36.    rescue_compound: COMPOUND;
  37.  
  38.    ensure_assertion: E_ENSURE;
  39.  
  40.    is_deferred: BOOLEAN is false;
  41.  
  42.    is_once_procedure: BOOLEAN is false;
  43.  
  44.    is_once_function: BOOLEAN is true;
  45.  
  46.    is_static: BOOLEAN is false;
  47.  
  48.    static_value_mem: INTEGER is 0;
  49.  
  50.    afd_check is
  51.       do
  52.          routine_afd_check;
  53.       end;
  54.  
  55.    is_pre_computable: BOOLEAN is
  56.       do
  57.      Result := once_routine_pool.is_pre_computable(Current);
  58.       end;
  59.  
  60.    can_be_dropped: BOOLEAN is
  61.       do
  62.          Result := is_pre_computable;
  63.       end;
  64.  
  65.    mapping_c is
  66.       do
  67.          if is_pre_computable then
  68.             once_routine_pool.c_put_o_result(Current);
  69.          else
  70.             default_mapping_function;
  71.          end;
  72.       end;
  73.  
  74.    c_define is
  75.       do
  76.      once_routine_pool.c_define_o_result(Current);
  77.          if not is_pre_computable then
  78.         once_routine_pool.c_define_o_flag(Current);
  79.             define_prototype;
  80.         once_routine_pool.c_test_o_flag(Current);
  81.             c_define_opening;
  82.         if routine_body /= Void then
  83.                routine_body.compile_to_c;
  84.             end;
  85.             c_define_closing;
  86.         once_routine_pool.c_return_o_result(Current);
  87.             c_frame_descriptor;
  88.          end;
  89.       end;
  90.  
  91.    mapping_jvm is
  92.       do
  93.          routine_mapping_jvm;
  94.       end;
  95.  
  96. feature {CALL_PROC_CALL}
  97.  
  98.    collect_c_tmp is
  99.       do
  100.       end;
  101.  
  102. feature {ADDRESS_OF_POOL}
  103.  
  104.    address_of_c_define(caller: ADDRESS_OF) is
  105.       do
  106.          if run_control.boost then
  107.             if use_current then
  108.             else
  109.                address_of_c_define_wrapper(caller);
  110.             end;
  111.          else
  112.             address_of_c_define_wrapper(caller);
  113.          end;
  114.       end;
  115.  
  116. feature {ADDRESS_OF}
  117.  
  118.    address_of_c_mapping is
  119.       do
  120.          if run_control.boost then
  121.             if use_current then
  122.                mapping_name;
  123.             else
  124.                address_of_c_mapping_wrapper;
  125.             end;
  126.          else
  127.             address_of_c_mapping_wrapper;
  128.          end;
  129.       end;
  130.  
  131. feature {RUN_CLASS}
  132.  
  133.    jvm_field_or_method is
  134.       do
  135.          jvm.add_method(Current);
  136.       end;
  137.  
  138. feature {JVM}
  139.  
  140.    jvm_define is
  141.       local
  142.          branch, idx_flag: INTEGER;
  143.          ca: like code_attribute;
  144.       do
  145.          ca := code_attribute;
  146.          idx_flag := once_routine_pool.idx_fieldref_for_flag(Current);
  147.          method_info_start;
  148.          ca.opcode_getstatic(idx_flag,1);
  149.          branch := ca.opcode_ifne;
  150.          ca.opcode_iconst_1;
  151.          ca.opcode_putstatic(idx_flag,-1);
  152.          jvm_define_opening;
  153.          if routine_body /= Void then
  154.             routine_body.compile_to_jvm;
  155.          end;
  156.          jvm_define_closing;
  157.          ca.resolve_u2_branch(branch);
  158.          once_routine_pool.jvm_result_load(Current);
  159.          result_type.run_type.jvm_return_code;
  160.          method_info.finish;
  161.       end;
  162.  
  163. feature {NONE}
  164.  
  165.    initialize is
  166.       do
  167.          result_type := base_feature.result_type;
  168.          arguments := base_feature.arguments;
  169.          if result_type.is_anchored then
  170.             fe_vffd7;
  171.          elseif result_type.is_formal_generic then
  172.             eh.add_position(result_type.start_position);
  173.             fatal_error("Result type of a once function must %
  174.                         %not be a formal generic argument (VFFD.7).");
  175.          end;
  176.          result_type := result_type.to_runnable(current_type);
  177.          if arguments /= Void then
  178.             if not arguments.is_runnable(current_type) then
  179.                !!arguments.with(arguments,current_type);
  180.             end;
  181.          end;
  182.          local_vars := base_feature.local_vars;
  183.          if local_vars /= Void then
  184.             local_vars := local_vars.to_runnable(current_type);
  185.          end;
  186.          routine_body := base_feature.routine_body;
  187.          if routine_body /= Void then
  188.             routine_body := routine_body.to_runnable(current_type);
  189.          end;
  190.          if run_control.require_check then
  191.             require_assertion := run_require;
  192.          end;
  193.          if run_control.ensure_check then
  194.             ensure_assertion := run_ensure;
  195.          end;
  196.          rescue_compound := base_feature.rescue_compound;
  197.          if rescue_compound = Void then
  198.             rescue_compound := default_rescue_compound;
  199.          end;
  200.          if rescue_compound /= Void then
  201.             exceptions_handler.set_used;
  202.             rescue_compound := rescue_compound.to_runnable(current_type);
  203.          end;
  204.          once_routine_pool.register_function(Current);
  205.       end;
  206.  
  207.    compute_use_current is
  208.       do
  209.          std_compute_use_current;
  210.       end;
  211.  
  212.    compute_stupid_switch(r: ARRAY[RUN_CLASS]) is
  213.       do
  214.          std_compute_stupid_switch(r);
  215.       end;
  216.  
  217.    update_tmp_jvm_descriptor is
  218.       do
  219.          routine_update_tmp_jvm_descriptor;
  220.       end;
  221.  
  222.    stupid_switch_comment: STRING is "SSORRF6";
  223.  
  224. end -- RUN_FEATURE_6
  225.